/**
 * 这里存放的是对Category的操作。
 */
import { ajaxTcbCloud } from "@/utils/cloud";
import { successResponseType, failRejectType } from "CustomTypes";

/**
 * 获取数据
 */
export const getCategorys = (
  parentId = "0"
): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/manage/category/list", { parentId });
/**
 * 添加数据
 */
export const addCategorys = (
  name: string,
  parentId: string
): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/manage/category/add", {
    categoryName: name,
    parentId
  });
/**
 * 更新数据
 */
export const updateCategorys = (
  _id: string,
  name: string
): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/manage/category/update", {
    categoryId: _id,
    categoryName: name
  });
/**
 * 获取小程序中的导航栏的图片、名字等。
 */
export const reqNavInfo = (): Promise<any> =>
  ajaxTcbCloud("/manage/category/navInfo");
